package jw.hospital.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import jw.hospital.cmn.mapper.DictMapper;
import jw.hospital.hosp.model.cmn.Dict;
import jw.hospital.hosp.vo.DictVo;
import org.springframework.beans.BeanUtils;

public class DicListener extends AnalysisEventListener<DictVo> {
    private DictMapper  dictMapper;

    public DicListener(DictMapper dictMapper) {
        this.dictMapper = dictMapper;
    }

    @Override
    public void invoke(DictVo dictVo, AnalysisContext analysisContext) {
        //调用方法添加数据
        Dict dic = new Dict();
        BeanUtils.copyProperties(dictVo,dic);
        dictMapper.insert(dic);

    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
